import { createRouter, createWebHistory } from 'vue-router';

import{ RouteRecordRaw } from 'vue-router';

import HomeView from '../views/HomeView.vue'



declare module 'vue-router'{
    interface RouteMeta{
        //可选
        isAdmin?:boolean
        //每个路由都必须声明
        requiresAuth:boolean
    }
}


const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta:{
        requiresAuth:true,
    }
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

//router.beforeEach((to,from,next)=>{})



export default router
